import requests
import time

# import zh as zh

headers ={
    'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
    'Accept-Encoding':'gzip,deflate',
    'Accept-Language':'zh-CN,zh;q=0.9',
    'User-Agent':'Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,like Gecko/74.0.3729.108 Safari/537.36'
}
def get_dydata(i):
    url='http://www.job5156.com/s/result/ajax.json?keyword=&keywordType=0&posTypeList=&locationList=14010000%2C14030000%2C14020000&taoLabelList=&degreeFrom=&propertyList=&industryList=&sorBy=0&urgentFlag=&maxSalary=&salary=&worjyearFrom=&workyearTo=&degreeTo=&pageNo={ }'.format(i)
    response=requests.get(url,headers=headers).text
    response=response.replace('null','None').replace('false','False').replace('true','True')
    response=eval(response)
    for a in response['page']['items']:
        comname=a['comName']
        addr=a['workLocationsStr']
        if a['educationDegreeStr']=='':
            req=a['reqWorkYearStr']
        else:
            r1=a['educationDegreeStr']
            r2=a['reqWorkYearStr']
            req=r1+','+r2
            salary=a['salaryStr']
            #name=a['posName'].replace('<em><em>',").replace('</em></em>',")
            name=a['paoName']
            desc=a['industryStr']
            print(comname,addr,req,salary,name,desc)
            if __name__=='__main__':
                for i in range(1,200):
                    get_dydata(i)
                    time.sleep(1)